<style>
	.scroll {
		height: 100%;
		box-sizing: border-box;
	}
	.scroll .list-scroll{
		height: 100%;
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
	}
</style>
<template>
	<view class="scroll flex-1">
		<!-- <button type="default" @click="goTop">top</button> -->
		<scroll-view class="list-scroll" scroll-y @scrolltolower="loadmore" @scrolltoupper ="refresh" @scroll="scroll" :scroll-top="scrollTop">
			<slot></slot>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		name:"list-scroll",
		data() {
			return {
				oldScrollTop:100,
				scrollTop:0
			};
		},
		created() {
			let _this = this
			uni.$on('update_scroll_top',()=>{
				_this.goTop()
			})
		},
		/* onShow() {
			this.$nextTick(() => {
				this.scrollTop = 0
				console.log('update_scroll_top');
			});
		}, */
		methods:{
			loadmore(){
				this.$emit('loadmore','list-more')
			},
			refresh(){
				this.$emit('refresh','list-refresh')
			},
			scroll(e){
				this.oldScrollTop = e.detail.scrollTop
			},
			goTop() {
				let _this = this
				_this.scrollTop = this.oldScrollTop
				_this.$nextTick(() => {
					_this.scrollTop = 0
					uni.setStorageSync('is_to_top',0)
				});
			}
		}
	}
</script>

